package com.ssh;

import org.junit.Test;

public class LongestCommonPrefix_14 {
	public String longestCommonPrefix(String[] strs) {
		if (strs.length == 0) {
			return "";
		}
        String s = strs[0];
        for (int i = 1; i < strs.length; i++) {
        	int x = 0;
        	for (int j = 0; j < strs[i].length(); j++) {
        		System.out.println("s.length()-1="+(s.length()-1));
        		if (s.length()-1 >= j && s.charAt(j) == strs[i].charAt(j)) {
        			x++;
        			System.out.println("x="+x);
        		}else {
        			break;
        		}
        	}
        	s = s.substring(0, x);
        }
        return s;
    }
	/*@Test
	public void test () {
		String[] strs = {"abcss","abcs","asss"};
		System.out.println(longestCommonPrefix(strs));
	}*/
	
	@Test
	public void test1 () {
		String a = "qwer";
		String b = "er";
		System.out.println(a.indexOf(b));
		
		
	}
}
